package com.hjm.project.accounts.virtualPolicyRecord.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.accounts.virtualPolicyRecord.domain.VirtualPolicyRecord;
import com.hjm.project.accounts.virtualPolicyRecord.service.IVirtualPolicyRecordService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import javax.annotation.Resource;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 商户提现规则记录Controller
 * 
 * @author maker-platform
 * @date 2022-03-14
 */
@Controller
@RequestMapping("/accounts/virtualPolicyRecord")
public class VirtualPolicyRecordController extends BaseController {
    private String prefix = "accounts/virtualPolicyRecord";

    @Resource
    private IVirtualPolicyRecordService virtualPolicyRecordService;

    @RequiresPermissions("accounts:virtualPolicyRecord:view")
    @GetMapping()
    public String virtualPolicyRecord() {
        return prefix + "/virtualPolicyRecord";
    }

    /**
     * 查询商户提现规则记录列表
     */
    @RequiresPermissions("accounts:virtualPolicyRecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(VirtualPolicyRecord virtualPolicyRecord) {
        startPage();
        List<VirtualPolicyRecord> list = virtualPolicyRecordService.selectVirtualPolicyRecordList(virtualPolicyRecord);
        return getDataTable(list);
    }

    /**
     * 导出商户提现规则记录列表
     */
    @RequiresPermissions("accounts:virtualPolicyRecord:export")
    @Log(title = "商户提现规则记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(VirtualPolicyRecord virtualPolicyRecord) {
        List<VirtualPolicyRecord> list = virtualPolicyRecordService.selectVirtualPolicyRecordList(virtualPolicyRecord);
        ExcelUtil<VirtualPolicyRecord> util = new ExcelUtil<VirtualPolicyRecord>(VirtualPolicyRecord.class);
        return util.exportExcel(list, "virtualPolicyRecord");
    }

    /**
     * 新增商户提现规则记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存商户提现规则记录
     */
    @RequiresPermissions("accounts:virtualPolicyRecord:add")
    @Log(title = "商户提现规则记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(VirtualPolicyRecord virtualPolicyRecord) {
        return toAjax(virtualPolicyRecordService.insertVirtualPolicyRecord(virtualPolicyRecord));
    }

    /**
     * 修改商户提现规则记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap) {
        VirtualPolicyRecord virtualPolicyRecord = virtualPolicyRecordService.selectVirtualPolicyRecordById(id);
        mmap.put("virtualPolicyRecord", virtualPolicyRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存商户提现规则记录
     */
    @RequiresPermissions("accounts:virtualPolicyRecord:edit")
    @Log(title = "商户提现规则记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(VirtualPolicyRecord virtualPolicyRecord) {
        return toAjax(virtualPolicyRecordService.updateVirtualPolicyRecord(virtualPolicyRecord));
    }

    /**
     * 删除商户提现规则记录
     */
    @RequiresPermissions("accounts:virtualPolicyRecord:remove")
    @Log(title = "商户提现规则记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(virtualPolicyRecordService.deleteVirtualPolicyRecordByIds(ids));
    }
}
